/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    hansen
 * 创建时间:    2024-01-26
 */
package org.jeecg.modules.dock.entity.vms.response;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.util.Json;
import lombok.Data;
import lombok.ToString;
import org.jeecg.modules.dock.entity.BaseResponseV0;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 信号触发接口响应实体
 *
 * @author hansen
 * @version 1.0.0
 * @date 2024-01-26 09:07:59
 */
@ApiModel(value = "vms响应实体", description = "vms响应实体")
@Data
@ToString(callSuper = true)
public class VMSResponseVO extends BaseResponseV0 {

    @ApiModelProperty("响应信息: 200正常, 504错误")
    private String status;

    @ApiModelProperty("响应数据")
    @NotNull
    private List<Detail> reason;

    @Data
    public static class Detail implements Serializable {
        @ApiModelProperty("对应编码")
        private String code;
        @ApiModelProperty("状态")
        private String val;
    }

    public VMSResponseVO() {
    }

    public static VMSResponseVO ok() {
        VMSResponseVO responseVO = new VMSResponseVO();
        responseVO.setStatus("200");
        responseVO.setTarget(SUCCESS);
        responseVO.setMsg("请求成功");
        return responseVO;
    }

    public static VMSResponseVO ok(String data) {
        VMSResponseVO responseVO = new VMSResponseVO();
        VMSResponseVO vmsResponseVO = JSON.parseObject(data, VMSResponseVO.class);
        responseVO.setStatus(vmsResponseVO.getStatus());
        responseVO.setReason(vmsResponseVO.getReason());
        responseVO.setTarget(SUCCESS);
        responseVO.setMsg("请求成功");
        return responseVO;
    }

    public static VMSResponseVO failure(String data) {
        VMSResponseVO responseVO = new VMSResponseVO();
        responseVO.setStatus("504");
        responseVO.setTarget(ERROR);
        responseVO.setMsg("请求失败");
        return responseVO;
    }

    public static VMSResponseVO failure() {
        VMSResponseVO responseVO = new VMSResponseVO();
        responseVO.setStatus("504");
        responseVO.setTarget(ERROR);
        responseVO.setMsg("请求失败");
        return responseVO;
    }
}
